package io.network;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

public class URLTyper {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		if (args.length != 1) {
			throw new IllegalArgumentException("Usage: java URLTyper url");
		}
		InputStream in = null;
		try {
			URL url = new URL(args[0]);
			in = url.openStream();
			for (int c = in.read(); c != -1; c = in.read()) {
				System.out.write(c);
			}
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (in != null) {
					in.close();
					in = null;
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}
